<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./vue.js"></script>
</head>
<body>
    <div id="app">
        <!-- <div>
            <input type="text">
            <ul>
                <li>熊大</li>
                <li>熊二</li>
                <li>光头强</li>
            </ul>
        </div> -->
        <da></da>
    </div>
</body>
<script>

    Vue.component("da",{
        data(){
            return {
                inputval:"",
                showhide:false
            }
        },
        methods:{
            xianshi(){
                this.showhide=true;
            },
            shou(can){
                this.inputval=can;
                this.showhide=false;
            }
        },
        template:
        `<div>
            <input type="text" v-model="inputval" v-on:focus="xianshi()">
            <xiao v-show="showhide==true" v-on:chuanzhi="shou"></xiao>
        </div>`
    })

    Vue.component("xiao",{
        data(){
            return{
                "info":[
                    {"name":"熊大"},
                    {"name":"熊二"},
                    {"name":"光头强"}
                ]
            }
        },
        methods:{
            chuan(x){
                this.$emit("chuanzhi",x)
            }
        },
        template:
            `<ul>
                <li v-for="(v,i) in info" :key="i" v-on:click="chuan(v.name)">{{v.name}}</li>
            </ul>`
    })




    let v= new Vue({
        el:"#app"
    })

</script>
</html>